import React from 'react'
import Alert from '@material-ui/lab/Alert';
import './FAlert.less'
import { connect } from 'react-redux'
function FAlert(props) {
    return (
        // 封装的Alert
        <Alert
            // 判断props.alertShow是否满足
            style={{ display: props.alertShow ? 'flex' : 'none' }}
            className="f-alert" variant="filled"
            // 传入alert的类型
            severity={props.alertType}>
            {/* 传入的信息 */}
            {props.alertMsg}
        </Alert>
    )
}

// 获取仓库的数据
const mapStateToProps = (state) => {
    return {
        alertType: state.alertType,
        alertMsg: state.alertMsg,
        alertShow: state.alertShow,
    }
}

export default connect(mapStateToProps, null)(FAlert)
